<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>

  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <title>7 Glossary | Tidy evaluation</title>
  <meta name="description" content="这本书的目的是让你跟上 tidy evaluation 的进度，以及如何围绕 tidyverse 流程和语法编写函数" />
  <meta name="generator" content="bookdown 0.11 and GitBook 2.6.7" />

  <meta property="og:title" content="7 Glossary | Tidy evaluation" />
  <meta property="og:type" content="book" />
  
  
  <meta property="og:description" content="这本书的目的是让你跟上 tidy evaluation 的进度，以及如何围绕 tidyverse 流程和语法编写函数" />
  <meta name="github-repo" content="ShixiangWang/tidyeval-chinese" />

  <meta name="twitter:card" content="summary" />
  <meta name="twitter:title" content="7 Glossary | Tidy evaluation" />
  
  <meta name="twitter:description" content="这本书的目的是让你跟上 tidy evaluation 的进度，以及如何围绕 tidyverse 流程和语法编写函数" />
  

<meta name="author" content="Lionel Henry" />
<meta name="author" content="Hadley Wickham" />
<meta name="author" content="王诗翔（译）" />



  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  
  
<link rel="prev" href="modifying-inputs.html">
<link rel="next" href="dplyr.html">
<script src="libs/jquery-2.2.3/jquery.min.js"></script>
<link href="libs/gitbook-2.6.7/css/style.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-table.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-bookdown.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-highlight.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-search.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-fontsettings.css" rel="stylesheet" />







<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-115082821-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-115082821-1');
</script>


<style type="text/css">
a.sourceLine { display: inline-block; line-height: 1.25; }
a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; }
a.sourceLine:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode { white-space: pre; position: relative; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
code.sourceCode { white-space: pre-wrap; }
a.sourceLine { text-indent: -1em; padding-left: 1em; }
}
pre.numberSource a.sourceLine
  { position: relative; left: -4em; }
pre.numberSource a.sourceLine::before
  { content: attr(data-line-number);
    position: relative; left: -1em; text-align: right; vertical-align: baseline;
    border: none; pointer-events: all; display: inline-block;
    -webkit-touch-callout: none; -webkit-user-select: none;
    -khtml-user-select: none; -moz-user-select: none;
    -ms-user-select: none; user-select: none;
    padding: 0 4px; width: 4em;
    color: #aaaaaa;
  }
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa;  padding-left: 4px; }
div.sourceCode
  {  }
@media screen {
a.sourceLine::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>

<link rel="stylesheet" href="adv-r.css" type="text/css" />
</head>

<body>



  <div class="book without-animation with-summary font-size-2 font-family-1" data-basepath=".">

    <div class="book-summary">
      <nav role="navigation">

<ul class="summary">
<li><strong><a href="./">Tidy evaluation</a></strong></li>

<li class="divider"></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html"><i class="fa fa-check"></i>欢迎</a><ul>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html#e585b6e4bb96e8b584e6ba90"><i class="fa fa-check"></i>其他资源</a></li>
</ul></li>
<li class="part"><span><b>I 原理</b></span></li>
<li class="chapter" data-level="1" data-path="section-1.html"><a href="section-1.html"><i class="fa fa-check"></i><b>1</b> 介绍</a></li>
<li class="chapter" data-level="2" data-path="sec-why-how.html"><a href="sec-why-how.html"><i class="fa fa-check"></i><b>2</b> 为什么使用以及怎么使用</a><ul>
<li class="chapter" data-level="2.1" data-path="sec-why-how.html"><a href="sec-why-how.html#section-2.1"><i class="fa fa-check"></i><b>2.1</b> 数据隐藏</a></li>
<li class="chapter" data-level="2.2" data-path="sec-why-how.html"><a href="sec-why-how.html#section-2.2"><i class="fa fa-check"></i><b>2.2</b> 引用代码</a></li>
<li class="chapter" data-level="2.3" data-path="sec-why-how.html"><a href="sec-why-how.html#section-2.3"><i class="fa fa-check"></i><b>2.3</b> 去引用代码</a></li>
</ul></li>
<li class="chapter" data-level="3" data-path="sec-do-you-need.html"><a href="sec-do-you-need.html"><i class="fa fa-check"></i><b>3</b> 你需要 tidy eval 吗？</a><ul>
<li class="chapter" data-level="3.1" data-path="sec-do-you-need.html"><a href="sec-do-you-need.html#sec:fixed-colnames"><i class="fa fa-check"></i><b>3.1</b> 固定列名</a></li>
<li class="chapter" data-level="3.2" data-path="sec-do-you-need.html"><a href="sec-do-you-need.html#sec:automating-loops"><i class="fa fa-check"></i><b>3.2</b> 自动循环</a><ul>
<li class="chapter" data-level="3.2.1" data-path="sec-do-you-need.html"><a href="sec-do-you-need.html#dplyr-"><i class="fa fa-check"></i><b>3.2.1</b> dplyr 中的向量化</a></li>
<li class="chapter" data-level="3.2.2" data-path="sec-do-you-need.html"><a href="sec-do-you-need.html#section-3.2.2"><i class="fa fa-check"></i><b>3.2.2</b> 按列循环</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="4" data-path="sec-up-to-speed.html"><a href="sec-up-to-speed.html"><i class="fa fa-check"></i><b>4</b> 加速</a><ul>
<li class="chapter" data-level="4.1" data-path="sec-up-to-speed.html"><a href="sec-up-to-speed.html#section-4.1"><i class="fa fa-check"></i><b>4.1</b> 编写函数</a><ul>
<li class="chapter" data-level="4.1.1" data-path="sec-up-to-speed.html"><a href="sec-up-to-speed.html#section-4.1.1"><i class="fa fa-check"></i><b>4.1.1</b> 减少重复</a></li>
<li class="chapter" data-level="4.1.2" data-path="sec-up-to-speed.html"><a href="sec-up-to-speed.html#section-4.1.2"><i class="fa fa-check"></i><b>4.1.2</b> 引用函数的特殊之处在哪？</a></li>
<li class="chapter" data-level="4.1.3" data-path="sec-up-to-speed.html"><a href="sec-up-to-speed.html#section-4.1.3"><i class="fa fa-check"></i><b>4.1.3</b> 去引用</a></li>
<li class="chapter" data-level="4.1.4" data-path="sec-up-to-speed.html"><a href="sec-up-to-speed.html#-qq_show-"><i class="fa fa-check"></i><b>4.1.4</b> 通过 <code>qq_show()</code> 理解 <code>!!</code></a></li>
</ul></li>
<li class="chapter" data-level="4.2" data-path="sec-up-to-speed.html"><a href="sec-up-to-speed.html#section-4.2"><i class="fa fa-check"></i><b>4.2</b> 引用和去引用</a><ul>
<li class="chapter" data-level="4.2.1" data-path="sec-up-to-speed.html"><a href="sec-up-to-speed.html#section-4.2.1"><i class="fa fa-check"></i><b>4.2.1</b> 第一步：抽取</a></li>
<li class="chapter" data-level="4.2.2" data-path="sec-up-to-speed.html"><a href="sec-up-to-speed.html#section-4.2.2"><i class="fa fa-check"></i><b>4.2.2</b> 第二步：引用</a></li>
<li class="chapter" data-level="4.2.3" data-path="sec-up-to-speed.html"><a href="sec-up-to-speed.html#section-4.2.3"><i class="fa fa-check"></i><b>4.2.3</b> 第三步：去引用</a></li>
<li class="chapter" data-level="4.2.4" data-path="sec-up-to-speed.html"><a href="sec-up-to-speed.html#section-4.2.4"><i class="fa fa-check"></i><b>4.2.4</b> 结果</a></li>
</ul></li>
<li class="chapter" data-level="4.3" data-path="sec-up-to-speed.html"><a href="sec-up-to-speed.html#section-4.3"><i class="fa fa-check"></i><b>4.3</b> 用字符串取代引用</a><ul>
<li class="chapter" data-level="4.3.1" data-path="sec-up-to-speed.html"><a href="sec-up-to-speed.html#section-4.3.1"><i class="fa fa-check"></i><b>4.3.1</b> 字符串</a></li>
<li class="chapter" data-level="4.3.2" data-path="sec-up-to-speed.html"><a href="sec-up-to-speed.html#section-4.3.2"><i class="fa fa-check"></i><b>4.3.2</b> 包含列名的字符串向量</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="5" data-path="multiple.html"><a href="multiple.html"><i class="fa fa-check"></i><b>5</b> Dealing with multiple arguments</a><ul>
<li class="chapter" data-level="5.1" data-path="multiple.html"><a href="multiple.html#the-...-argument"><i class="fa fa-check"></i><b>5.1</b> The <code>...</code> argument</a></li>
<li class="chapter" data-level="5.2" data-path="multiple.html"><a href="multiple.html#simple-forwarding-of-..."><i class="fa fa-check"></i><b>5.2</b> Simple forwarding of <code>...</code></a></li>
<li class="chapter" data-level="5.3" data-path="multiple.html"><a href="multiple.html#quote-multiple-arguments"><i class="fa fa-check"></i><b>5.3</b> Quote multiple arguments</a></li>
<li class="chapter" data-level="5.4" data-path="multiple.html"><a href="multiple.html#unquote-multiple-arguments"><i class="fa fa-check"></i><b>5.4</b> Unquote multiple arguments</a></li>
</ul></li>
<li class="chapter" data-level="6" data-path="modifying-inputs.html"><a href="modifying-inputs.html"><i class="fa fa-check"></i><b>6</b> Modifying inputs</a><ul>
<li class="chapter" data-level="6.1" data-path="modifying-inputs.html"><a href="modifying-inputs.html#modifying-names"><i class="fa fa-check"></i><b>6.1</b> Modifying names</a><ul>
<li class="chapter" data-level="6.1.1" data-path="modifying-inputs.html"><a href="modifying-inputs.html#default-argument-names"><i class="fa fa-check"></i><b>6.1.1</b> Default argument names</a></li>
<li class="chapter" data-level="6.1.2" data-path="modifying-inputs.html"><a href="modifying-inputs.html#unquoting-argument-names"><i class="fa fa-check"></i><b>6.1.2</b> Unquoting argument names</a></li>
<li class="chapter" data-level="6.1.3" data-path="modifying-inputs.html"><a href="modifying-inputs.html#prefixing-quoted-arguments"><i class="fa fa-check"></i><b>6.1.3</b> Prefixing quoted arguments</a></li>
</ul></li>
<li class="chapter" data-level="6.2" data-path="modifying-inputs.html"><a href="modifying-inputs.html#modifying-quoted-expressions"><i class="fa fa-check"></i><b>6.2</b> Modifying quoted expressions</a><ul>
<li class="chapter" data-level="6.2.1" data-path="modifying-inputs.html"><a href="modifying-inputs.html#expanding-quoted-expressions-with-expr"><i class="fa fa-check"></i><b>6.2.1</b> Expanding quoted expressions with <code>expr()</code></a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="7" data-path="glossary.html"><a href="glossary.html"><i class="fa fa-check"></i><b>7</b> Glossary</a><ul>
<li class="chapter" data-level="7.1" data-path="glossary.html"><a href="glossary.html#data-structures"><i class="fa fa-check"></i><b>7.1</b> Data structures</a><ul>
<li class="chapter" data-level="7.1.1" data-path="glossary.html"><a href="glossary.html#glossary-data-mask"><i class="fa fa-check"></i><b>7.1.1</b> TODO Data mask</a></li>
<li class="chapter" data-level="7.1.2" data-path="glossary.html"><a href="glossary.html#glossary-expr"><i class="fa fa-check"></i><b>7.1.2</b> Expression</a></li>
<li class="chapter" data-level="7.1.3" data-path="glossary.html"><a href="glossary.html#expression-base"><i class="fa fa-check"></i><b>7.1.3</b> Expression (base)</a></li>
<li class="chapter" data-level="7.1.4" data-path="glossary.html"><a href="glossary.html#glossary-sym"><i class="fa fa-check"></i><b>7.1.4</b> TODO Symbol</a></li>
</ul></li>
<li class="chapter" data-level="7.2" data-path="glossary.html"><a href="glossary.html#programming-concepts"><i class="fa fa-check"></i><b>7.2</b> Programming Concepts</a><ul>
<li class="chapter" data-level="7.2.1" data-path="glossary.html"><a href="glossary.html#glossary-constant-symbolic"><i class="fa fa-check"></i><b>7.2.1</b> Constant versus symbolic</a></li>
<li class="chapter" data-level="7.2.2" data-path="glossary.html"><a href="glossary.html#glossary-nse"><i class="fa fa-check"></i><b>7.2.2</b> TODO Non-Standard Evaluation (NSE)</a></li>
<li class="chapter" data-level="7.2.3" data-path="glossary.html"><a href="glossary.html#glossary-quotation-evaluation"><i class="fa fa-check"></i><b>7.2.3</b> TODO Quotation versus Evaluation</a></li>
<li class="chapter" data-level="7.2.4" data-path="glossary.html"><a href="glossary.html#glossary-qq"><i class="fa fa-check"></i><b>7.2.4</b> TODO Quasiquotation</a></li>
<li class="chapter" data-level="7.2.5" data-path="glossary.html"><a href="glossary.html#glossary-parse"><i class="fa fa-check"></i><b>7.2.5</b> TODO Parsing</a></li>
<li class="chapter" data-level="7.2.6" data-path="glossary.html"><a href="glossary.html#glossary-metaprogramming"><i class="fa fa-check"></i><b>7.2.6</b> TODO Metaprogramming</a></li>
</ul></li>
</ul></li>
<li class="part"><span><b>II Cookbooks</b></span></li>
<li class="chapter" data-level="8" data-path="dplyr.html"><a href="dplyr.html"><i class="fa fa-check"></i><b>8</b> dplyr</a><ul>
<li class="chapter" data-level="8.1" data-path="dplyr.html"><a href="dplyr.html#patterns-for-single-arguments"><i class="fa fa-check"></i><b>8.1</b> Patterns for single arguments</a><ul>
<li class="chapter" data-level="8.1.1" data-path="dplyr.html"><a href="dplyr.html#enquo-and---quote-and-unquote-arguments"><i class="fa fa-check"></i><b>8.1.1</b> <code>enquo()</code> and <code>!!</code> - Quote and unquote arguments</a></li>
<li class="chapter" data-level="8.1.2" data-path="dplyr.html"><a href="dplyr.html#quo_name---create-default-column-names"><i class="fa fa-check"></i><b>8.1.2</b> <code>quo_name()</code> - Create default column names</a></li>
<li class="chapter" data-level="8.1.3" data-path="dplyr.html"><a href="dplyr.html#and---unquote-column-names"><i class="fa fa-check"></i><b>8.1.3</b> <code>:=</code> and <code>!!</code> - Unquote column names</a></li>
</ul></li>
<li class="chapter" data-level="8.2" data-path="dplyr.html"><a href="dplyr.html#patterns-for-multiple-arguments"><i class="fa fa-check"></i><b>8.2</b> Patterns for multiple arguments</a><ul>
<li class="chapter" data-level="8.2.1" data-path="dplyr.html"><a href="dplyr.html#forward-multiple-arguments"><i class="fa fa-check"></i><b>8.2.1</b> <code>...</code> - Forward multiple arguments</a></li>
<li class="chapter" data-level="8.2.2" data-path="dplyr.html"><a href="dplyr.html#enquos-and---quote-and-unquote-multiple-arguments"><i class="fa fa-check"></i><b>8.2.2</b> <code>enquos()</code> and <code>!!!</code> - Quote and unquote multiple arguments</a></li>
<li class="chapter" data-level="8.2.3" data-path="dplyr.html"><a href="dplyr.html#expr---modify-quoted-arguments"><i class="fa fa-check"></i><b>8.2.3</b> <code>expr()</code> - Modify quoted arguments</a></li>
<li class="chapter" data-level="8.2.4" data-path="dplyr.html"><a href="dplyr.html#sec:external-quoting"><i class="fa fa-check"></i><b>8.2.4</b> <code>vars()</code> - Quote multiple arguments externally</a></li>
<li class="chapter" data-level="8.2.5" data-path="dplyr.html"><a href="dplyr.html#enquos.named-true---automatically-add-default-names"><i class="fa fa-check"></i><b>8.2.5</b> <code>enquos(.named = TRUE)</code> - Automatically add default names</a></li>
<li class="chapter" data-level="8.2.6" data-path="dplyr.html"><a href="dplyr.html#quos_auto_name---manually-add-default-names"><i class="fa fa-check"></i><b>8.2.6</b> <code>quos_auto_name()</code> - Manually add default names</a></li>
</ul></li>
<li class="chapter" data-level="8.3" data-path="dplyr.html"><a href="dplyr.html#select"><i class="fa fa-check"></i><b>8.3</b> <code>select()</code></a></li>
<li class="chapter" data-level="8.4" data-path="dplyr.html"><a href="dplyr.html#filter"><i class="fa fa-check"></i><b>8.4</b> <code>filter()</code></a></li>
<li class="chapter" data-level="8.5" data-path="dplyr.html"><a href="dplyr.html#case_when"><i class="fa fa-check"></i><b>8.5</b> <code>case_when()</code></a></li>
<li class="chapter" data-level="8.6" data-path="dplyr.html"><a href="dplyr.html#gotchas"><i class="fa fa-check"></i><b>8.6</b> Gotchas</a><ul>
<li class="chapter" data-level="8.6.1" data-path="dplyr.html"><a href="dplyr.html#nested-quoting-functions"><i class="fa fa-check"></i><b>8.6.1</b> Nested quoting functions</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="9" data-path="ggplot2.html"><a href="ggplot2.html"><i class="fa fa-check"></i><b>9</b> ggplot2</a></li>
<li class="part"><span><b>III Going further</b></span></li>
<li class="chapter" data-level="10" data-path="a-rich-toolbox.html"><a href="a-rich-toolbox.html"><i class="fa fa-check"></i><b>10</b> A rich toolbox</a><ul>
<li class="chapter" data-level="10.1" data-path="a-rich-toolbox.html"><a href="a-rich-toolbox.html#todo-quote-expr-and-enexpr"><i class="fa fa-check"></i><b>10.1</b> TODO <code>quote()</code>, <code>expr()</code> and <code>enexpr()</code></a></li>
<li class="chapter" data-level="10.2" data-path="a-rich-toolbox.html"><a href="a-rich-toolbox.html#todo-quo-and-enquo"><i class="fa fa-check"></i><b>10.2</b> TODO <code>quo()</code> and <code>enquo()</code></a></li>
<li class="chapter" data-level="10.3" data-path="a-rich-toolbox.html"><a href="a-rich-toolbox.html#todo-vars-quos-and-enquos"><i class="fa fa-check"></i><b>10.3</b> TODO <code>vars()</code>, <code>quos()</code> and <code>enquos()</code></a></li>
<li class="chapter" data-level="10.4" data-path="a-rich-toolbox.html"><a href="a-rich-toolbox.html#toolbox-qq-show"><i class="fa fa-check"></i><b>10.4</b> TODO <code>qq_show()</code></a></li>
<li class="chapter" data-level="10.5" data-path="a-rich-toolbox.html"><a href="a-rich-toolbox.html#todo-sym-and-syms"><i class="fa fa-check"></i><b>10.5</b> TODO <code>sym()</code> and <code>syms()</code></a></li>
</ul></li>
<li class="chapter" data-level="11" data-path="creating-grammars.html"><a href="creating-grammars.html"><i class="fa fa-check"></i><b>11</b> Creating grammars</a></li>
</ul>

      </nav>
    </div>

    <div class="book-body">
      <div class="body-inner">
        <div class="book-header" role="navigation">
          <h1>
            <i class="fa fa-circle-o-notch fa-spin"></i><a href="./">Tidy evaluation</a>
          </h1>
        </div>

        <div class="page-wrapper" tabindex="-1" role="main">
          <div class="page-inner">

            <section class="normal" id="section-">
<div id="glossary" class="section level1">
<h1><span class="header-section-number">7</span> Glossary</h1>
<p>This glossary contains the vocabulary necessary to work with tidy evaluation and, more generally, with <a href="glossary.html#glossary-expr">expressions</a>. The definitions in rlang are generally consistent with base R. When they differ, both definitions are presented so you can navigate between these two worlds more easily.</p>
<div id="data-structures" class="section level2">
<h2><span class="header-section-number">7.1</span> Data structures</h2>
<div id="glossary-data-mask" class="section level3">
<h3><span class="header-section-number">7.1.1</span> TODO Data mask</h3>
</div>
<div id="glossary-expr" class="section level3">
<h3><span class="header-section-number">7.1.2</span> Expression</h3>
<p>An expression is a piece of R code that represents a value or a computation:</p>
<pre class="sourceCode r"><code class="sourceCode r"><span class="dv">12</span>            <span class="co"># Value</span>
<span class="dv">12</span> <span class="op">/</span><span class="st"> </span><span class="dv">3</span>        <span class="co"># Computation</span>
<span class="dv">12</span> <span class="op">/</span><span class="st"> </span>(<span class="dv">1</span> <span class="op">+</span><span class="st"> </span><span class="dv">2</span>)  <span class="co"># Nested computations</span></code></pre>
<p>Expressions are normally transient. They are computed (or <a href="#glossary-eval">evaluated</a>) when you source a file or call a function. You can only observe:</p>
<ul>
<li><p>The final value of the outermost expression.</p></li>
<li><p>Their side effects, such as the console output of a <code>print()</code> expression inside a loop.</p></li>
</ul>
<p>In R however, it is possible to suspend the normal evaluation of expressions with the <a href="#glossary-quotation">quotation</a> mechanism. In a way, quotation causes expressions to freeze in place:</p>
<pre class="sourceCode r"><code class="sourceCode r"><span class="co"># Evaluated expression</span>
<span class="dv">12</span> <span class="op">/</span><span class="st"> </span><span class="dv">3</span>
<span class="co">#&gt; [1] 4</span>

<span class="co"># Quoted expression</span>
<span class="kw">expr</span>(<span class="dv">12</span> <span class="op">/</span><span class="st"> </span><span class="dv">3</span>)
<span class="co">#&gt; 12/3</span></code></pre>
<p>The technical definition of expressions is any R object that is created by <a href="glossary.html#glossary-parse">parsing</a> R code:</p>
<ul>
<li><a href="glossary.html#glossary-constant-symbolic">Constants</a> like <code>NULL</code>, <code>1</code>, <code>&quot;foo&quot;</code>, <code>TRUE</code>, <code>NA</code>, etc.</li>
<li><a href="glossary.html#glossary-sym">Symbols</a> like <code>height</code> or <code>weight</code></li>
<li><a href="#glossary-call">Calls</a> like <code>c()</code> or <code>list()</code></li>
</ul>
<p>Unlike constants, symbols and calls are <a href="glossary.html#glossary-constant-symbolic">symbolic</a> objects: their <a href="#glossary-eval">value</a> depends on the <a href="#glossary-env">environment</a>.</p>
</div>
<div id="expression-base" class="section level3">
<h3><span class="header-section-number">7.1.3</span> Expression (base)</h3>
<p>In base R, “expression” refers to a special type of vector that contains quoted expressions in the rlang sense:</p>
<pre class="sourceCode r"><code class="sourceCode r">base<span class="op">::</span><span class="kw">expression</span>(key &lt;-<span class="st"> &quot;foo&quot;</span>, <span class="kw">toupper</span>(key))
<span class="co">#&gt; expression(key &lt;- &quot;foo&quot;, toupper(key))</span></code></pre>
<p>You’ll most likely encounter this rare data structure as the return value of <code>base::parse()</code>:</p>
<pre class="sourceCode r"><code class="sourceCode r">code &lt;-<span class="st"> &quot;key &lt;- &#39;foo&#39;; toupper(key)&quot;</span>
<span class="kw">parse</span>(<span class="dt">text =</span> code)
<span class="co">#&gt; expression(key &lt;- &quot;foo&quot;, toupper(key))</span></code></pre>
<p>The only advantage of expression vectors compared to lists is that they include <strong>source references</strong>. Expression vectors with source references are printed with whitespace and comments preserved:</p>
<pre class="sourceCode r"><code class="sourceCode r">code &lt;-<span class="st"> &quot;{</span>
<span class="st">  # Interesting comment</span>
<span class="st">  weird     &lt;-     whitespace</span>
<span class="st">}&quot;</span>
<span class="kw">parse</span>(<span class="dt">text =</span> code, <span class="dt">keep.source =</span> <span class="ot">TRUE</span>)
<span class="co">#&gt; expression({</span>
<span class="co">#&gt;   # Interesting comment</span>
<span class="co">#&gt;   weird     &lt;-     whitespace</span>
<span class="co">#&gt; })</span></code></pre>
<p>Source references are mostly useful for debugging and development tools. They don’t play any computational role and tidy evaluation doesn’t make use of references. Consequently the parsing tools in rlang return normal lists of expressions (in the rlang sense) instead of expression vectors:</p>
<pre class="sourceCode r"><code class="sourceCode r">rlang<span class="op">::</span><span class="kw">parse_exprs</span>(code)
<span class="co">#&gt; [[1]]</span>
<span class="co">#&gt; {</span>
<span class="co">#&gt;     weird &lt;- whitespace</span>
<span class="co">#&gt; }</span></code></pre>
</div>
<div id="glossary-sym" class="section level3">
<h3><span class="header-section-number">7.1.4</span> TODO Symbol</h3>
</div>
</div>
<div id="programming-concepts" class="section level2">
<h2><span class="header-section-number">7.2</span> Programming Concepts</h2>
<div id="glossary-constant-symbolic" class="section level3">
<h3><span class="header-section-number">7.2.1</span> Constant versus symbolic</h3>
<p>Constants, also called “literals”, always have the same value no matter the context. On the other hand, symbols and calls are <a href="glossary.html#glossary-constant-symbolic">symbolic</a> expressions: their value depends on an <a href="#glossary-env">environment</a> and what kind of objects are defined there.</p>
<p>For instance the string <code>&quot;mickey&quot;</code> always represents the same string no matter the environment and what objects are defined there:</p>
<pre class="sourceCode r"><code class="sourceCode r"><span class="co"># Here&#39;s a string:</span>
<span class="st">&quot;mickey&quot;</span>
<span class="co">#&gt; [1] &quot;mickey&quot;</span>

mickey &lt;-<span class="st"> &quot;mouse&quot;</span>

<span class="co"># Still the same string:</span>
<span class="st">&quot;mickey&quot;</span>
<span class="co">#&gt; [1] &quot;mickey&quot;</span></code></pre>
<p>In constrast, <a href="glossary.html#glossary-sym">symbols</a> depend on current definitions:</p>
<pre class="sourceCode r"><code class="sourceCode r"><span class="co"># We&#39;ve defined `mickey` as &quot;mouse&quot;</span>
mickey
<span class="co">#&gt; [1] &quot;mouse&quot;</span>

mickey &lt;-<span class="st"> &quot;mickey&quot;</span>

<span class="co"># Now `mickey` is &quot;mickey&quot;</span>
mickey
<span class="co">#&gt; [1] &quot;mickey&quot;</span></code></pre>
<p>One source of problems when you’re working with quoted expressions is that they might be evaluated in arbitrary places, where objects have potentially been redefined to something different than expected. This is a common issue with tidyverse grammars because they evaluate quoted expressions in a <a href="glossary.html#glossary-data-mask">data mask</a>. Say you’d like to divide a column by a factor defined in the current environment:</p>
<pre class="sourceCode r"><code class="sourceCode r">factor &lt;-<span class="st"> </span><span class="dv">100</span>

starwars <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">mutate</span>(height <span class="op">/</span><span class="st"> </span>factor) <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">pull</span>()
<span class="co">#&gt;  [1] 1.72 1.67 0.96 2.02 1.50 1.78 1.65 0.97 1.83 1.82 1.88 1.80 2.28 1.80</span>
<span class="co">#&gt; [15] 1.73 1.75 1.70 1.80 0.66 1.70 1.83 2.00 1.90 1.77 1.75 1.80 1.50   NA</span>
<span class="co">#&gt; [29] 0.88 1.60 1.93 1.91 1.70 1.96 2.24 2.06 1.83 1.37 1.12 1.83 1.63 1.75</span>
<span class="co">#&gt; [43] 1.80 1.78 0.94 1.22 1.63 1.88 1.98 1.96 1.71 1.84 1.88 2.64 1.88 1.96</span>
<span class="co">#&gt; [57] 1.85 1.57 1.83 1.83 1.70 1.66 1.65 1.93 1.91 1.83 1.68 1.98 2.29 2.13</span>
<span class="co">#&gt; [71] 1.67 0.79 0.96 1.93 1.91 1.78 2.16 2.34 1.88 1.78 2.06   NA   NA   NA</span>
<span class="co">#&gt; [85]   NA   NA 1.65</span></code></pre>
<p>This works fine but what if the data frame contains a column called <code>factor</code>? The expression will be evaluated with the parasite definition:</p>
<pre class="sourceCode r"><code class="sourceCode r"><span class="co"># Derive a data frame that contains a `factor` column</span>
starwars2 &lt;-<span class="st"> </span>starwars <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">mutate</span>(<span class="dt">factor =</span> <span class="dv">1</span><span class="op">:</span><span class="kw">n</span>())

<span class="co"># Oh no! We&#39;re now dividing `height` by the new column!</span>
starwars2 <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">mutate</span>(height <span class="op">/</span><span class="st"> </span>factor) <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">pull</span>()
<span class="co">#&gt;  [1] 172.0  83.5  32.0  50.5  30.0  29.7  23.6  12.1  20.3  18.2  17.1</span>
<span class="co">#&gt; [12]  15.0  17.5  12.9  11.5  10.9  10.0  10.0   3.5   8.5   8.7   9.1</span>
<span class="co">#&gt; [23]   8.3   7.4   7.0   6.9   5.6    NA   3.0   5.3   6.2   6.0   5.2</span>
<span class="co">#&gt; [34]   5.8   6.4   5.7   4.9   3.6   2.9   4.6   4.0   4.2   4.2   4.0</span>
<span class="co">#&gt; [45]   2.1   2.7   3.5   3.9   4.0   3.9   3.4   3.5   3.5   4.9   3.4</span>
<span class="co">#&gt; [56]   3.5   3.2   2.7   3.1   3.0   2.8   2.7   2.6   3.0   2.9   2.8</span>
<span class="co">#&gt; [67]   2.5   2.9   3.3   3.0   2.4   1.1   1.3   2.6   2.5   2.3   2.8</span>
<span class="co">#&gt; [78]   3.0   2.4   2.2   2.5    NA    NA    NA    NA    NA   1.9</span></code></pre>
<p>Masking is generally not a problem in scripts because you know what columns are inside your data frame. However as soon as your code is getting more general, for instance if you create a reusable function, you can no longer make assumptions about what’s in the data.</p>
<p>Fortunately with <a href="glossary.html#glossary-qq">quasiquotation</a> it is easy to solve masking issues by replacing symbols with constants. The unquoting operator <code>!!</code> allows you to inline constant values deep inside expressions. With <a href="a-rich-toolbox.html#toolbox-qq-show"><code>qq_show()</code></a> we can observe the inlining:</p>
<pre class="sourceCode r"><code class="sourceCode r">vector &lt;-<span class="st"> </span><span class="dv">1</span><span class="op">:</span><span class="dv">3</span>

<span class="co"># Without inlining, the expression depends on the value of `vector`:</span>
rlang<span class="op">::</span><span class="kw">qq_show</span>(<span class="kw">list</span>(vector))
<span class="co">#&gt; list(vector)</span>

<span class="co"># Let&#39;s inline the current value of `vector` by unquoting it:</span>
rlang<span class="op">::</span><span class="kw">qq_show</span>(<span class="kw">list</span>(<span class="op">!!</span>vector))
<span class="co">#&gt; list(&lt;int: 1L, 2L, 3L&gt;)</span></code></pre>
<p>Because constants have the same value in any environment, the data mask can never take over with parasite definitions:</p>
<pre class="sourceCode r"><code class="sourceCode r">rlang<span class="op">::</span><span class="kw">qq_show</span>(starwars2 <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">mutate</span>(height <span class="op">/</span><span class="st"> </span><span class="op">!!</span>factor) <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">pull</span>())
<span class="co">#&gt; starwars2 %&gt;% mutate(height / 100) %&gt;% pull()</span>

starwars2 <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">mutate</span>(height <span class="op">/</span><span class="st"> </span><span class="op">!!</span>factor) <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">pull</span>()
<span class="co">#&gt;  [1] 1.72 1.67 0.96 2.02 1.50 1.78 1.65 0.97 1.83 1.82 1.88 1.80 2.28 1.80</span>
<span class="co">#&gt; [15] 1.73 1.75 1.70 1.80 0.66 1.70 1.83 2.00 1.90 1.77 1.75 1.80 1.50   NA</span>
<span class="co">#&gt; [29] 0.88 1.60 1.93 1.91 1.70 1.96 2.24 2.06 1.83 1.37 1.12 1.83 1.63 1.75</span>
<span class="co">#&gt; [43] 1.80 1.78 0.94 1.22 1.63 1.88 1.98 1.96 1.71 1.84 1.88 2.64 1.88 1.96</span>
<span class="co">#&gt; [57] 1.85 1.57 1.83 1.83 1.70 1.66 1.65 1.93 1.91 1.83 1.68 1.98 2.29 2.13</span>
<span class="co">#&gt; [71] 1.67 0.79 0.96 1.93 1.91 1.78 2.16 2.34 1.88 1.78 2.06   NA   NA   NA</span>
<span class="co">#&gt; [85]   NA   NA 1.65</span></code></pre>
</div>
<div id="glossary-nse" class="section level3">
<h3><span class="header-section-number">7.2.2</span> TODO Non-Standard Evaluation (NSE)</h3>
</div>
<div id="glossary-quotation-evaluation" class="section level3">
<h3><span class="header-section-number">7.2.3</span> TODO Quotation versus Evaluation</h3>
</div>
<div id="glossary-qq" class="section level3">
<h3><span class="header-section-number">7.2.4</span> TODO Quasiquotation</h3>
</div>
<div id="glossary-parse" class="section level3">
<h3><span class="header-section-number">7.2.5</span> TODO Parsing</h3>
</div>
<div id="glossary-metaprogramming" class="section level3">
<h3><span class="header-section-number">7.2.6</span> TODO Metaprogramming</h3>

</div>
</div>
</div>



            </section>

          </div>
        </div>
      </div>
<a href="modifying-inputs.html" class="navigation navigation-prev " aria-label="Previous page"><i class="fa fa-angle-left"></i></a>
<a href="dplyr.html" class="navigation navigation-next " aria-label="Next page"><i class="fa fa-angle-right"></i></a>
    </div>
  </div>
<script src="libs/gitbook-2.6.7/js/app.min.js"></script>
<script src="libs/gitbook-2.6.7/js/lunr.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-search.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-sharing.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-fontsettings.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-bookdown.js"></script>
<script src="libs/gitbook-2.6.7/js/jquery.highlight.js"></script>
<script>
gitbook.require(["gitbook"], function(gitbook) {
gitbook.start({
"sharing": {
"github": true,
"facebook": false,
"twitter": false,
"google": false,
"linkedin": false,
"weibo": false,
"instapaper": false,
"vk": false,
"all": ["facebook", "google", "twitter", "linkedin", "weibo", "instapaper"]
},
"fontsettings": {
"theme": "white",
"family": "sans",
"size": 2
},
"edit": {
"link": "https://github.com/ShixiangWang/tidyeval/edit/master/glossary.Rmd",
"text": "Edit"
},
"history": {
"link": null,
"text": null
},
"download": null,
"toc": {
"collapse": "section"
}
});
});
</script>

</body>

</html>
